<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>作品列表</title>
<link href="../style/common.css" rel="stylesheet" type="text/css" />
<link href="../style/painting.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.ciyi_type{margin: 0 auto;width: 960px;background-color: #ffffff;border: 1px solid #ccc;margin-top: 5px;}
.title_ciyi{font-size: 12px;}
.nodata{display:none; height:32px; line-height:32px; text-align:center; color:#999; font-size:14px}
</style>
</head>
<body>

<%@include file="/commons/head.jsp"%>

<div style="border: 1px solid #ccc;background: #ffffff;margin: 0 auto;width: 960px;height: 245px;margin-top: 5px;">
	  	<%@ include file="/front/common/ad_fragment.jsp" %>
</div>

<div class="main" style="margin-top: 5px;">
		<div style="margin: 10px 0px 0px 0px;"></div>
	   	<c:forEach items="${page.result}" var="result" varStatus="status">
			<%@ include file="/ciyi/ciyi_fragment.jsp" %>
		</c:forEach>
	<div id="container" style="font-size: 14px;"></div>
    <div class="nodata">加载数据</div> 
</div>
<%@include file="/commons/foot.jsp" %>
<script type="text/javascript">

var cur_page = '${page.pageNo}';

$(function(){

	var j = 1;
	var winH = $(window).height(); //页面可视区域高度
	$(window).scroll(function () {
		var scrollT = document.documentElement.scrollTop + document.body.scrollTop;
		var pageH = $(document.body).height();
		var winH = $(window).height(); //页面可视区域高度
		var aa = (pageH-winH-scrollT)/winH;  
		if ( aa<0.02 ) {
			if (j >= 10) {
				if(cur_page < total_page){
					var next_page = cur_page+1;
					$(".nodata").show().html("别滚动了，已经到底了。。。<a href=\"${ctx}/p/paintingAction!pList.do?type=${param.type}&pageNo="+next_page+"\">下一页</a>");
				}else{
					$(".nodata").show().html("别滚动了，已经到底了。。。");
				}
				return; //控制最大只能加载10页
			}
			cur_page++;
			j++;
			getData_by_page(cur_page);
		}
	});
});

function getData_by_page(page){
	$.getJSON("${ctx}/p/paintingAction!query_ajax2.do?type=${param.type}",{pageNo:page},function(json){
		if(json){
			var page = json.page;
			var arrays = json.array;
			cur_page = page.pageNo;
			total_page = page.pageCount;
			var str = "";
			$.each(arrays,function(index,array){
				if(index%4 == 0){
					str +='<div class="row">';
				}
				str += '<div class="list"><div class="item">';
				str += '<div style="background-image: url(\''+array['middleImageApath']+'\');" class="pic">';
				str += '<a href="${ctx}/front/backgroundAction!showDetail.do?id='+array['id']+'"></a>';
				str += '<div style="position: absolute;top: -23px;left: -25px">';
				var onSaleFlag = array['onSaleFlag'];
				var store = array['store'];
				if( onSaleFlag == '2' && store == 0){
					str += '<div style="text-align:center;width: 90px;height:29px;padding-top:10px;color: #ffffff;font-size: 15px;font-weight: bold;background-repeat: no-repeat;background: url("../images/ciyi/sale_bg.png");">售罄</div>';
				}
				str += '</div></div></div>';
				str += '<div class="title_ciyi"><div style="text-align: center;padding: 5px 0px 5px 0px;line-height: 22px;width: 210px;overflow: hidden;">'+array['painterName']+'&nbsp;《'+array['title']+'》';
				var remark = array['remark'];
				if(remark=='1'){
					str += '(真迹)';
				}
				else if(remark=='2'){
					str += '(高仿)';
				}

				str += '</div><div style="padding: 0px 0px 10px 0px;width: 210px;font-size: 12px;"><div style="float: left;min-width: 75px;">';
				var qqxl = array['qqxl'];
				var unit = array['unit'];
				if(qqxl > 0){
					str += '全球限量'+qqxl+unit;
				}
				str += '</div><div style="float: left;padding-left: 20px;">';

				var onSaleFlag = array['onSaleFlag'];
				var bidPrice = array['bidPrice'];
				if( onSaleFlag == '1' ){
					str += '起拍价：<span style="color: red"><em class="tb-rmb">¥</em>'+bidPrice+'元</span>';
				}

				var price = array['price'];
				if(price >0 ){
					str += '<span style="color: red"><em class="tb-rmb">¥</em>'+price+'元</span>';
				}

				str += '</div><div style="clear: both;"></div></div></div></div>';
				
                if(index == json.length -1 || (index+1) % 4 == 0){
					str +='<div style="clear: both;"></div></div>';
                }
			});
			$("#container").append(str);
		}else{
			$(".nodata").show().html("别滚动了，本页已到底。。。");
			return false;
		}
	});
}
</script>
</body>

</html>